home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Modules / BackSpaceModules / Source / ItJustStopped / ItJustStoppedViewPart.m < prev    next >
Text File  |  1994-05-04  |  2KB  |  111 lines

  1. #import "ItJustStoppedViewPart.h"
  2. #import "Thinker.h"
  3. #import <appkit/NXImage.h>
  4. #import <appkit/Window.h>
  5. #import <appkit/Panel.h>                // for NXRunAlertPanel()
  6. #import <dpsclient/wraps.h>
  7. #import <libc.h>
  8. #import <math.h>
  9.  
  10. @implementation ItJustStoppedView
  11.  
  12. - oneStep
  13. {
  14.   float mx, my;
  15.   float xi, yi;
  16.   
  17.   n=(n+1)%(NUMLINES-1);
  18.     
  19.   p=(p+1)%(NUMLINES-1);
  20.     
  21.   pp=(pp+1)%(NUMLINES-1);
  22.  
  23.   PScurrentmouse(winNum, &mx, &my);
  24.   xi=((mx-midx)/urx)*10.0;
  25.   yi=((my-midy)/ury)*10.0;
  26.  
  27.   if((count++>500) && (((mx != oldx) && (my != oldy)) || (count>30000))){
  28.     count=0;
  29.     PSsetgray(0.0);
  30.     NXRectFill(&bounds);
  31.   }
  32.   oldx=mx; oldy=my;
  33.  
  34.   t1[n]=t1[p]+0.2*xi; if(t1[n]>(2*PI)) t1[n]-=(2*PI);
  35.   t2[n]=t2[p]+0.2*yi; if(t2[n]>(2*PI)) t2[n]-=(2*PI);
  36.   t3[n]=t3[p]+0.01;   if(t3[n]>(2*PI)) t3[n]-=(2*PI);
  37.  
  38.   x1[n]=(cos(t1[n])*s1) + (cos(t2[n])*s3) + midx;
  39.   yc1[n]=(sin(t1[n])*s2) + (sin(t2[n])*s4) + midy;
  40.  
  41.   PSsetrgbcolor((cos(t1[n])+1.0)/2.0,
  42.                 (cos(t2[n])+1.0)/2.0,
  43.                 (cos(t3[n]*1.5)+1.0)/2.0);
  44.  
  45.   PSnewpath();
  46.   PSmoveto(x1[pp], yc1[pp]);
  47.   PSlineto(x1[p], yc1[p]);
  48.   PSlineto(x1[n], yc1[n]);
  49.   PSclosepath();
  50.   PSfill();
  51.  
  52.   return self;
  53. }
  54.  
  55. - initFrame:(NXRect *)frameRect
  56. {
  57.   [super initFrame:frameRect];
  58.   [self newSize];
  59.   winNum=[[self window] windowNum];
  60.   return self;
  61. }
  62.  
  63. - sizeTo:(NXCoord)width :(NXCoord)height
  64. {
  65.   [super sizeTo:width :height];
  66.   [self newSize];
  67.   return self;
  68. }
  69.  
  70. - newSize
  71. {
  72.   int jkl;
  73.   urx=bounds.size.width;
  74.   ury=bounds.size.height;
  75.   
  76.   midx=urx/2;
  77.   midy=ury/2;
  78.  
  79.   n = 0;
  80.   t = 0;
  81.   
  82.   // phases of the three points;
  83.   p1=0;
  84.   p2=(4*PI)/3;
  85.   p3=(2*PI)/3;
  86.   
  87.   // starting angle of each point;
  88.   t1[0]=0;
  89.   t2[0]=p2;
  90.   t3[0]=p3;
  91.  
  92.   for(jkl=0;jkl<NUMLINES;jkl++){
  93.     x1[jkl]=midx;
  94.     yc1[jkl]=midy;
  95.   }
  96.  
  97.   // s1 and s2 should define an oval that takes up middle 75% of the screen
  98.   s1 = midx*0.5; s2 = midy*0.5;
  99.   s3 = midx*0.5; s4 = midy*0.5;
  100.  
  101.   // line per is the percentage back that erase steps
  102.   lper=NUMLINES-5;
  103.  
  104.   n=lper;
  105.   p=(lper/3)*2;
  106.   pp=(lper/3);
  107.   return self;
  108. }
  109.  
  110. @end
  111.